Skip to content

feat(calculator): add "Copy for AI assistant" export button (#553)#569

Merged
Gregable merged 2 commits into
mainfrom
worktree-feat-553-copy-for-ai-button
Jun 19, 2026
Merged

feat(calculator): add "Copy for AI assistant" export button (#553)#569
Gregable merged 2 commits into
mainfrom
worktree-feat-553-copy-for-ai-button

Conversation

@Gregable

Copy link
Copy Markdown
Owner

Summary

Adds a Copy for AI section to the calculator report (just above More Reading) with a button that opens a preview modal of the full benefit-derivation markdown and copies it to the clipboard — for pasting into ChatGPT, Claude, or another AI assistant. Works for both single recipients and couples.

This is the Phase 2 UI for #553; it builds on the ai-export builder merged in #568.

What's included

  • copy-for-ai.ts (importable, unit-tested):
    • localIsoDate() — formats the "Generated" date from local calendar parts (avoids the toISOString() UTC off-by-one the builder docs warn about).
    • buildCalculatorExport(recipient, spouse | null, options) — dispatches to the single vs couple builder.
  • CopyForAiButton.svelte — trigger button styled as the report's primary CTA (matches StrategyPromo), opening a native <dialog> preview with: scrollable markdown, "Copy to clipboard" (→ "Copied!"), a PII disclosure, a copy-failure fallback, and a posthog event. The export is built lazily on open for determinism.
  • Wired into the calculator report (+page.svelte) as its own section + sidebar-nav entry.
  • Storybook story (single + couple) for Chromatic visual-regression coverage.

Privacy

All data stays client-side. The markdown is only built on demand and never leaves the device until the user pastes it; the modal warns about the birthdate/earnings/PIA it contains.

Testing

  • 9 new TDD unit tests (copy-for-ai.test.ts): date formatting/locality, single-vs-couple dispatch, generatedDate/baseUrl passthrough, determinism.
  • Full suite green: 2032 passed. npm run quality clean (Biome + svelte-check 0/0).
  • Manually verified end-to-end against a production preview build (button → modal → 23k-char couple export rendering with aligned tables).

Follow-ups (not in this PR)

  • Wire the same export into the /strategy report.
  • Optional: a one-line dev-server fix so npm run dev works with the COEP header (currently the dev runtime fails to load dynamic modules under require-corp).

Adds a "Copy for AI" section to the calculator report (above More Reading)
with a button that opens a preview modal of the full benefit-derivation
markdown and copies it to the clipboard, for pasting into an AI assistant.
Works for both single recipients and couples. Builds on the #553 ai-export
builder merged in #568.

- copy-for-ai.ts: localIsoDate (local YYYY-MM-DD, no UTC off-by-one) and a
  single/couple dispatch helper over the ai-export builders (unit tested).
- CopyForAiButton.svelte: trigger button styled as the report's primary CTA,
  opening a native <dialog> preview with clipboard copy, a PII disclosure,
  and a posthog event. Built lazily on open for determinism.
- Wired into the calculator report; Storybook story for Chromatic coverage.

All data stays client-side; the markdown is only built on demand and never
leaves the device until the user pastes it.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 19, 2026

Copy link
Copy Markdown

Deploying social-security-tools with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6c03f7f
Status: ✅  Deploy successful!
Preview URL: https://50720b4d.social-security-tools.pages.dev
Branch Preview URL: https://worktree-feat-553-copy-for-a.social-security-tools.pages.dev

View logs

- Clear the "Copied!" reset timer on component destroy (onDestroy), matching
  the timer-cleanup convention in Sidebar / MobileDesktopPrompt, so the
  callback can't assign state on a torn-down component.
- Add a regression test pinning the production default baseUrl through the
  no-options dispatch path (the live button's actual call shape).
- Clarify the determinism comment (the property comes from the delegate
  builder + module-load constants), narrow the timezone test comment, and
  document why the button is hidden in print.
@Gregable Gregable merged commit f9ba07b into main Jun 19, 2026
6 checks passed
@Gregable Gregable deleted the worktree-feat-553-copy-for-ai-button branch June 19, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant